﻿using MediatR;
using Traceability.App.Api.Application.Command.Basic;
using Traceability.App.ErrorCount;
using Traceability.App.InfrasIntructure;
using Traceability.App.Model.Basic;

namespace Traceability.App.Api.Application.Handler.Basic
{
    public class GetStoreHandler : IRequestHandler<GetStoreCommand, ApiResult<StoreModel>>
    {
        IBaseRepository<StoreModel> storeRepo;

        public GetStoreHandler(IBaseRepository<StoreModel> storeRepo)
        {
            this.storeRepo = storeRepo;
        }

        public Task<ApiResult<StoreModel>> Handle(GetStoreCommand request, CancellationToken cancellationToken)
        {
            ApiResult<StoreModel> res=new ApiResult<StoreModel>();
            var stores=storeRepo.GetAll().Where(c=>!c.IsDeleted);
            res.Msg = "查询商品名称成功";
            res.Code=ApiEnum.Success;
            res.Data=stores.ToList();
            return Task.FromResult(res);
        }
    }
}
